.class public Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;
.super Lorg/jboss/netty/handler/codec/http/HttpContentEncoder;
.source "HttpContentCompressor.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lorg/jboss/netty/handler/codec/http/HttpContentCompressor$1;
    }
.end annotation


# instance fields
.field private final compressionLevel:I

.field private final memLevel:I

.field private final windowBits:I


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 41
    const/4 v0, 0x6

    invoke-direct {p0, v0}, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;-><init>(I)V

    .line 42
    return-void
.end method

.method public constructor <init>(I)V
    .locals 2
    .parameter "compressionLevel"

    .prologue
    .line 54
    const/16 v0, 0xf

    const/16 v1, 0x8

    invoke-direct {p0, p1, v0, v1}, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;-><init>(III)V

    .line 55
    return-void
.end method

.method public constructor <init>(III)V
    .locals 3
    .parameter "compressionLevel"
    .parameter "windowBits"
    .parameter "memLevel"

    .prologue
    const/16 v1, 0x9

    .line 76
    invoke-direct {p0}, Lorg/jboss/netty/handler/codec/http/HttpContentEncoder;-><init>()V

    .line 77
    if-ltz p1, :cond_0

    if-le p1, v1, :cond_1

    .line 78
    :cond_0
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "compressionLevel: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " (expected: 0-9)"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 81
    :cond_1
    if-lt p2, v1, :cond_2

    const/16 v0, 0xf

    if-le p2, v0, :cond_3

    .line 82
    :cond_2
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "windowBits: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " (expected: 9-15)"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 85
    :cond_3
    const/4 v0, 0x1

    if-lt p3, v0, :cond_4

    if-le p3, v1, :cond_5

    .line 86
    :cond_4
    new-instance v0, Ljava/lang/IllegalArgumentException;

    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v2, "memLevel: "

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v2, " (expected: 1-9)"

    invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw v0

    .line 89
    :cond_5
    iput p1, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->compressionLevel:I

    .line 90
    iput p2, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->windowBits:I

    .line 91
    iput p3, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->memLevel:I

    .line 92
    return-void
.end method

.method private determineWrapper(Ljava/lang/String;)Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;
    .locals 13
    .parameter "acceptEncoding"

    .prologue
    const/high16 v12, -0x4080

    const/4 v11, 0x0

    .line 123
    const/high16 v9, -0x4080

    .line 124
    .local v9, starQ:F
    const/high16 v5, -0x4080

    .line 125
    .local v5, gzipQ:F
    const/high16 v1, -0x4080

    .line 126
    .local v1, deflateQ:F
    const-string v10, ","

    invoke-virtual {p1, v10}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v0

    .local v0, arr$:[Ljava/lang/String;
    array-length v7, v0

    .local v7, len$:I
    const/4 v6, 0x0

    .local v6, i$:I
    :goto_0
    if-ge v6, v7, :cond_4

    aget-object v3, v0, v6

    .line 127
    .local v3, encoding:Ljava/lang/String;
    const/high16 v8, 0x3f80

    .line 128
    .local v8, q:F
    const/16 v10, 0x3d

    invoke-virtual {v3, v10}, Ljava/lang/String;->indexOf(I)I

    move-result v4

    .line 129
    .local v4, equalsPos:I
    const/4 v10, -0x1

    if-eq v4, v10, :cond_0

    .line 131
    add-int/lit8 v10, v4, 0x1

    :try_start_0
    invoke-virtual {v3, v10}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v10

    invoke-static {v10}, Ljava/lang/Float;->valueOf(Ljava/lang/String;)Ljava/lang/Float;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/Float;->floatValue()F
    :try_end_0
    .catch Ljava/lang/NumberFormatException; {:try_start_0 .. :try_end_0} :catch_0

    move-result v8

    .line 137
    :cond_0
    :goto_1
    const-string v10, "*"

    invoke-virtual {v3, v10}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v10

    if-ltz v10, :cond_2

    .line 138
    move v9, v8

    .line 126
    :cond_1
    :goto_2
    add-int/lit8 v6, v6, 0x1

    goto :goto_0

    .line 132
    :catch_0
    move-exception v2

    .line 134
    .local v2, e:Ljava/lang/NumberFormatException;
    const/4 v8, 0x0

    goto :goto_1

    .line 139
    .end local v2           #e:Ljava/lang/NumberFormatException;
    :cond_2
    const-string v10, "gzip"

    invoke-virtual {v3, v10}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v10

    if-ltz v10, :cond_3

    cmpl-float v10, v8, v5

    if-lez v10, :cond_3

    .line 140
    move v5, v8

    goto :goto_2

    .line 141
    :cond_3
    const-string v10, "deflate"

    invoke-virtual {v3, v10}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v10

    if-ltz v10, :cond_1

    cmpl-float v10, v8, v1

    if-lez v10, :cond_1

    .line 142
    move v1, v8

    goto :goto_2

    .line 145
    .end local v3           #encoding:Ljava/lang/String;
    .end local v4           #equalsPos:I
    .end local v8           #q:F
    :cond_4
    cmpl-float v10, v5, v11

    if-gtz v10, :cond_5

    cmpl-float v10, v1, v11

    if-lez v10, :cond_7

    .line 146
    :cond_5
    cmpl-float v10, v5, v1

    if-ltz v10, :cond_6

    .line 147
    sget-object v10, Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;->GZIP:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    .line 160
    :goto_3
    return-object v10

    .line 149
    :cond_6
    sget-object v10, Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;->ZLIB:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    goto :goto_3

    .line 152
    :cond_7
    cmpl-float v10, v9, v11

    if-lez v10, :cond_9

    .line 153
    cmpl-float v10, v5, v12

    if-nez v10, :cond_8

    .line 154
    sget-object v10, Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;->GZIP:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    goto :goto_3

    .line 156
    :cond_8
    cmpl-float v10, v1, v12

    if-nez v10, :cond_9

    .line 157
    sget-object v10, Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;->ZLIB:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    goto :goto_3

    .line 160
    :cond_9
    const/4 v10, 0x0

    goto :goto_3
.end method


# virtual methods
.method protected getTargetContentEncoding(Ljava/lang/String;)Ljava/lang/String;
    .locals 3
    .parameter "acceptEncoding"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 107
    invoke-direct {p0, p1}, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->determineWrapper(Ljava/lang/String;)Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    move-result-object v0

    .line 108
    .local v0, wrapper:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;
    if-nez v0, :cond_0

    .line 109
    const/4 v1, 0x0

    .line 116
    :goto_0
    return-object v1

    .line 112
    :cond_0
    sget-object v1, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor$1;->$SwitchMap$org$jboss$netty$handler$codec$compression$ZlibWrapper:[I

    invoke-virtual {v0}, Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;->ordinal()I

    move-result v2

    aget v1, v1, v2

    packed-switch v1, :pswitch_data_0

    .line 118
    new-instance v1, Ljava/lang/Error;

    invoke-direct {v1}, Ljava/lang/Error;-><init>()V

    throw v1

    .line 114
    :pswitch_0
    const-string v1, "gzip"

    goto :goto_0

    .line 116
    :pswitch_1
    const-string v1, "deflate"

    goto :goto_0

    .line 112
    nop

    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
    .end packed-switch
.end method

.method protected newContentEncoder(Ljava/lang/String;)Lorg/jboss/netty/handler/codec/embedder/EncoderEmbedder;
    .locals 8
    .parameter "acceptEncoding"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Lorg/jboss/netty/handler/codec/embedder/EncoderEmbedder",
            "<",
            "Lorg/jboss/netty/buffer/ChannelBuffer;",
            ">;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 96
    invoke-direct {p0, p1}, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->determineWrapper(Ljava/lang/String;)Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;

    move-result-object v0

    .line 97
    .local v0, wrapper:Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;
    if-nez v0, :cond_0

    .line 98
    const/4 v1, 0x0

    .line 101
    :goto_0
    return-object v1

    :cond_0
    new-instance v1, Lorg/jboss/netty/handler/codec/embedder/EncoderEmbedder;

    const/4 v2, 0x1

    new-array v2, v2, [Lorg/jboss/netty/channel/ChannelDownstreamHandler;

    const/4 v3, 0x0

    new-instance v4, Lorg/jboss/netty/handler/codec/compression/ZlibEncoder;

    iget v5, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->compressionLevel:I

    iget v6, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->windowBits:I

    iget v7, p0, Lorg/jboss/netty/handler/codec/http/HttpContentCompressor;->memLevel:I

    invoke-direct {v4, v0, v5, v6, v7}, Lorg/jboss/netty/handler/codec/compression/ZlibEncoder;-><init>(Lorg/jboss/netty/handler/codec/compression/ZlibWrapper;III)V

    aput-object v4, v2, v3

    invoke-direct {v1, v2}, Lorg/jboss/netty/handler/codec/embedder/EncoderEmbedder;-><init>([Lorg/jboss/netty/channel/ChannelDownstreamHandler;)V

    goto :goto_0
.end method
